const mysql = require('mysql')
const $conf = require('../config/db.js')
const $sql = require('./memberMapping.js')

const pool = mysql.createPool($conf.mysql)

function response(res, result) {
    if(result){
        res.json(result)
    }
}

module.exports = {
    queryMajor(req, res ,next) {
        console.log('进入dao')
        pool.getConnection((err, connection) => {
            console.log('获取连接')
            console.log($sql)
            connection.query($sql.member.queryMajor, (err, result) => {
                if(!err) {
                    console.log(result)
                    response(res, result)
                    connection.release()
                }
            })
        })
    }
}